package com.example.pathprotectsystem.mapper;
import com.example.pathprotectsystem.pojo.Password;
import com.example.pathprotectsystem.pojo.User;
import org.apache.ibatis.annotations.*;
import java.util.List;
@Mapper
public interface UserMapper {
    //根据用户名查询用户
    @Select("select * from user where userName=#{username}")
    User findByUserName(String username);
    //添加用户
    @Insert("insert into user(userName,passWord,createTime,updateTime,userType)" +
            "values(#{username},#{md5String},now(),now(),#{usertype})")
    void add(String username, String md5String,String usertype);
    //更新用户信息
    @Update("update user set userName=#{userName},userType=#{userType},nickName=#{nickName},email=#{email},updateTime=now() where id=#{id}")
    void update(User user);
    //更新密码
    @Update("update user set passWord=#{newPassword},updateTime=now() where id=#{id}")
    void updatePwd(Password password);
    @Update("update user set userPic=#{userPic} ,updateTime=now() where id=#{id}")
    void updateavatar(User user);
    @Delete("delete from user where id=#{id}")
    void delete(Integer id);
    @Update("update user set passWord=#{initWord},updateTime=now() where id=#{id}")
    void initPassWord(String initWord,Integer id);


    List<User> listpart(String str);

    @Select("select userName from user where userType<>'普通用户'")
    List<String> getpersons();
    @Select("select id from user where userName=#{userName}")
    int findUserIdByUserName(String userName);

}
